package com.droid.mvvmlib.router;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 *
 * @author zhyuc
 * @since  2019/10/26 9:31
 */
public class RouterProxy implements IRouter {

    private final String TAG = "RouterProxy";
    private IRouter iArouter;

    private static class SingletonHolder {
        private static final RouterProxy intance = new RouterProxy();
    }

    public static RouterProxy getInstance() {
        return SingletonHolder.intance;
    }

    public void init (IRouter iArouter) {
        this.iArouter = iArouter;
    }

    @Override
    public void startActivity(Activity context, @NonNull String path) {
        iArouter.startActivity(context, path, -1);
    }

    @Override
    public void startActivity(Activity context, @NonNull String path, int flags) {
        iArouter.startActivity(context, path, null, flags);
    }

    @Override
    public void startActivity(Activity context, @NonNull String path, @Nullable Bundle bundle, int flags) {
        iArouter.startActivity(context, path, bundle, flags, null, -1);
    }

    @Override
    public void startActivity(Activity context, @NonNull String path, int flags, int reqCode) {
        iArouter.startActivity(context, path, flags, reqCode);
    }

    @Override
    public void startActivity(Activity context, @NonNull String path, @Nullable Bundle bundle, int flags, int reqCode) {
        iArouter.startActivity(context, path, bundle, flags, null, reqCode);
    }

    @Override
    public void startActivity(Activity context, @NonNull String path, @Nullable Bundle bundle, int flags, IRouterCallBack callBack, int reqCode) {
        iArouter.startActivity(context, path, bundle, flags, callBack, reqCode);
    }
}
